<extend name="Base/common"/>
<block name="head">
    <style type="text/css">
        html, body {
            background-color: #F5FFF5;
        }

        .bgimg {
            width: 100%;
            height: 400px;
            background-image: url(__PUBLIC__/images/bg3.jpg);
            background-position: top;
            background-repeat: no-repeat;
            background-size: 100% 400px;
        }

        .apply {
            margin-top: -280px;
            width: 40%;
            background-color: #F5FFF5;
            border-radius: 10px;
        }

        .apply img {
            width: 200px;
        }

        .apply p {
            margin-top: 40px;
        }

        .apply input {
            padding: 6px 12px;
            font-size: 14px;
            font-weight: normal;
            line-height: 1.42857143;
            text-align: center;
            white-space: nowrap;
            vertical-align: middle;
            /*-ms-touch-action: manipulation;
            touch-action: manipulation;*/
            cursor: pointer;
            /*-webkit-user-select: none;
            -moz-user-select: none;
            -ms-user-select: none;
            user-select: none;*/
            background-image: none;
            border: 2px solid #f4eabe;
            border-radius: 8px;
            width: 100px;
            height: 50px;
            margin-top: 50px;
            background-color: rgba(245, 255, 245, 1);
        }

        .watchinfo {
            width: 200px;
            height: 300px;
            /*background-color: #E6F0FF;*/
            background-color: white;
            position: absolute;
            top: 450px;
            right: 120px;
            box-shadow: 0 2px 2px rgba(0, 0, 0, 0.15), 0 8px 20px rgba(0, 0, 0, 0.19);
        }

        .watchinfo p {
            margin-top: 50px;
            vertical-align: middle;
            font-size: 20px;
            word-wrap: break-word;
        }

        .watchinfo-bottom {
            width: 300px;
            height: 150px;
            /*background-color: #E6F0FF;*/
            background-color: white;
            box-shadow: 0 2px 2px rgba(0, 0, 0, 0.15), 0 8px 20px rgba(0, 0, 0, 0.19);
            border: 2px solid #f4eabe;
            border-radius: 8px;
            margin-top: 50px;
            padding: 20px;
            display: none;
        }

        .watchinfo-bottom p {
            font-size: 18px;
        }

        .fixed-div {
            width: 100%;
            height: 1080px;
            position: fixed;
            top: 0;
            left: 0;
            background-color: white;
            opacity: 0.5;
            z-index: 10;
            display: none;
        }

        .form {
            position: fixed;
            width: 350px;
            background-color: white;
            top: 45%;
            left: 50%;
            margin-top: -150px;
            margin-left: -175px;
            z-index: 100;
            border-radius: 12px;
            display: none;
            box-shadow: 0 2px 2px rgba(0, 0, 0, 0.15), 0 8px 20px rgba(0, 0, 0, 0.19);
        }

        .form form {
            margin-top: 9%;
            width: 80%;
        }

        .input .authcode {
            color: white;
            vertical-align: middle;
        }

        .input .authcode input {
            height: 30px;
            width: 50% !important;
            color: black;
        }

        .input .authcode img {
            width: 50% !important;
            height: 30px;
        }

        .input .input-group {
            margin: 15px auto;
        }

        .input .userlogin {
            width: 50%;
            min-width: 200px;
            margin-top: 20px;
        }

        .userlogin a {
            color: black;
        }

        .registerinput form {
            overflow: hidden;
            margin-bottom: 0;
            margin-top: -10px;
        }

        .registerinput .input-group {
            margin: 15px auto;
        }

        .registerinput .errorInfo {
            color: red;
            margin: 7px auto;
            font-size: 16px;
            font-family: 微软雅黑;
            display: none;
        }

        .registerinput .registerlogin {
            width: 50%;
            min-width: 200px;
        }

        .registerinput #messegeRegister {
            display: none;
        }

        .registerlogin a {
            color: black;
        }

        .register-nav ul {
            list-style-type: none;
            margin-top: 20px;
            border-bottom: 1px solid #c7c7c7;
        }

        .register-nav ul li {
            display: inline-block;
            text-align: center;
            width: 70px;
            border: 1px solid #c7c7c7;
            margin-bottom: -1px;
            border-bottom: 1px solid white;
        }

        @media (max-width: 1200px) {
            .bgimg {
                width: 100%;
                height: 400px;
                background-image: url(__PUBLIC__/images/bg3.jpg);
                background-position: top;
                background-repeat: no-repeat;
                background-size: 1200px 400px;
                overflow: hidden;
            }

            .apply {
                margin-top: -300px;
                width: 50%;
                background-color: #F5FFF5;
                border-radius: 10px;
            }

            .apply img {
                width: 150px;
            }

            .watchinfo {
                display: none;
            }

            .watchinfo-bottom {
                display: block;
            }
        }

        @media (max-width: 700px) {
            .bgimg {
                width: 100%;
                height: 350px;
                background-image: url(__PUBLIC__/images/bg3.jpg);
                background-position: top;
                background-repeat: no-repeat;
                background-size: 700px 350px;
            }

            .apply {
                margin-top: -230px;
                width: 60%;
            }

            .apply img {
                width: 100px;
            }

            .watchinfo-bottom {
                display: block;
            }
        }

        @media (max-width: 450px) {
            .bgimg {
                width: 100%;
                height: 350px;
                background-image: url(__PUBLIC__/images/bg3.jpg);
                background-position: top;
                background-repeat: no-repeat;
                background-size: 700px 350px;
            }

            .apply {
                margin-top: -250px;
                width: 80%;
            }

            .apply img {
                width: 100px;
            }

            .watchinfo-bottom {
                display: block;
            }
        }
    </style>
</block>
<block name="body">
    <div class="bgimg">
        <!-- 这是北京 -->
    </div>
    <!-- 这是主页的内容部分 -->
    <div class="apply center-block text-center">
        <div>
            <img class="text-center" src="__PUBLIC__/images/welcome.jpg" style="margin: 15px auto;">
        </div>
        <!-- 这是logo -->
        <img src="__PUBLIC__/images/logo.jpg">
        <p>
            <b>2016年广东省标准舞、拉丁舞年度总决赛<br>暨第十届珠江三角洲标准舞、拉丁舞公开赛竞赛规程<br></b>
            一、主办单位：佛山市禅城区文化体育局<br>
            广东省青少年舞蹈协会<br>
            二、承办单位：佛山市运动家文化策划有限公司<br>
            三、竞赛时间和地点：2017年1月1日在佛山市体育馆举行
        </p>
        <input type="button" id="btn-opacity" onmouseover="btnOpacity($(this),1)" onmouseout="btnOpacity($(this),-1)"
               onclick="showForm(1,'#userRegister')" class="center-block" value="我要报名"/>
    </div>
    <!-- 这是右侧的消息栏部分 -->
    <div class="watchinfo text-center">
        <!-- <span class="glyphicon glyphicon-remove watchinfoclose" onclick="closeWindow($('.watchinfo'))"></span> -->
        <p>{$infor}</p>
    </div>
    <div class="fixed-div">
    <span class="glyphicon glyphicon-remove"
          style="position: absolute;right: 50px;top: 35px;font-size: 36px;cursor: pointer;"
          onclick="showForm(0)"></span>
    </div>
    <!-- 这是被隐藏的登录注册部分 -->
    <div class="input form">
        <!-- 登录部分 id：userLogin -->
        <form id="userLogin" name="main_login" class="center-block" action="" method="post" style="overflow: hidden;">
            <div class="form-group">
                <p class="text-center" style="font-size: 20px;">登录</p>
                <div class="input-group">
                    <span class="input-group-addon"><span class="glyphicon glyphicon-user"></span></span>
                    <input class="form-control" type="text" placeholder="输入用户名" name="user" maxlength="20">
                </div>
                <div class="input-group">
                    <span class="input-group-addon"><span class="glyphicon glyphicon-lock"></span></span>
                    <input class="form-control" type="password" placeholder="输入密码" name="password" maxlength="15">
                </div>
                <span class="pull-right"><a href="{:U('public/find_pwd')}">忘记密码？</a></span>
                <div class="authcode">
                    <label align="center" style="width:100%;">
                        <img src="{:U('Public/verify')}"
                             onclick="this.src='__ROOT__/Home/Public/verify/'+Math.random()"
                             class="pull-right"/>
                        <input type="text" name="captcha" style="width:100px;"/></label>
                </div>
                <if condition="!empty($error)"><p style="color: red;">{$error}{$eerror}</p></if>
                <div class="userlogin center-block">
                    <input type="submit" id="loginButton" value="登录" class="btn pull-left">
                    <input type="button" value="注册" class="btn pull-right" onclick="showForm(1,'#userLogin')">
                </div>
            </div>
        </form>
        <!-- 注册部分 id：userRegister -->
        <div class="registerinput" id="userRegister">
            <div class="register-nav">
                <ul>
                    <!--<li onclick="changeTab($(this),'#emailRegister')">邮箱注册</li>-->
                    <li onclick="changeTab($(this),'#messegeRegister')" id="reg-for-phone"
                        style="background-color: #c7c7c7;">短信注册
                    </li>
                </ul>
            </div>
            <div id="emailRegister" style="display: none">
                <form action="__URL__/register_email" method="post" class="center-block">
                    <div class="form-group">
                        <div class="input-group">
                            <span class="input-group-addon"><span class="glyphicon glyphicon-user"></span></span>
                            <input class="form-control" type="text" placeholder="请输入邮箱" name="user" id="Email"
                                   onkeyup="checkEmail()" maxlength="20">
                        </div>
                        <div class="input-group">
                            <span class="input-group-addon"><span class="glyphicon glyphicon-lock"></span></span>
                            <input id="password1" class="form-control" type="password" placeholder="请输入密码"
                                   name="password"
                                   onkeyup="emailCompare()" maxlength="15">
                        </div>
                        <div class="input-group">
                            <span class="input-group-addon"><span class="glyphicon glyphicon-lock"></span></span>
                            <input id="password2" class="form-control" type="password" placeholder="请确认密码"
                                   name="password"
                                   onkeyup="emailCompare()" maxlength="15">
                        </div>
                        <p class="errorInfo" id="Email-error">输入的邮箱格式不正确</p>
                        <p class="errorInfo" id="pwd-diferent">密码不一致</p>
                        <p class="errorInfo" id="pwd-empty">密码不能为空</p>
                        <div class="registerlogin center-block">
                            <input type="button" name="submit" value="登录" class="btn pull-left"
                                   onclick="showForm(1,'#userRegister')">
                            <input type="submit" id="eRegisterButton" name="register" value="注册" class="btn pull-right">
                        </div>
                    </div>
                </form>
            </div>
            <div id="messegeRegister">
                <form id="reg-phone-form" action="__URL__/register_phone" method="post" class="center-block"
                      name="messegeRegister">
                    <div class="form-group">
                        <div class="input-group" style="width: 280px;">
                            <!-- ajax -->
                            <input type="button" class="btn btn-get-phone" value="获取验证码"
                                   style="width: 36%;">
                            <input class="form-control" type="text" placeholder="请输入手机号" name="user" style="width: 64%;"
                                   maxlength="11" id="phone">
                        </div>
                        <div class="input-group">
                            <span class="input-group-addon"><span class="glyphicon glyphicon-envelope"></span></span>
                            <input class="form-control" id="check_code" type="text" placeholder="请输入手机验证码"
                                   name="check_code"
                                   maxlength="6">
                        </div>
                        <div class="input-group">
                            <span class="input-group-addon"><span class="glyphicon glyphicon-lock"></span></span>
                            <input id="messege-password1" class="form-control" type="password" placeholder="请输入密码"
                                   name="password" onkeyup="messegeCompare()" maxlength="15">
                        </div>
                        <div class="input-group">
                            <span class="input-group-addon"><span class="glyphicon glyphicon-lock"></span></span>
                            <input id="messege-password2" class="form-control" type="password" placeholder="请确认密码"
                                   name="password2" onkeyup="messegeCompare()" maxlength="15">
                        </div>

                        <div class="input-group">
                            <div>
                                <input type="radio" name="u_type" value="1">个人
                                <input type="radio" name="u_type" value="0">机构
                                <input type="radio" name="u_type" value="2" checked="checked">不确定
                            </div>
                        </div>


                        <p class="errorInfo" id="msg-pwd-diferent">密码不一致</p>
                        <p class="errorInfo" id="msg-pwd-empty">密码不能为空</p>
                        <div class="registerlogin center-block">
                            <input type="button" name="submit" value="登录" class="btn pull-left"
                                   onclick="showForm(1,'#userRegister')">
                            <input type="submit" id="mRegisterButton" name="register" value="注册" class="btn pull-right">
                        </div>
                    </div>
                </form>
            </div>
        </div>
        <div style="width: 100%;height: 25px;"></div>
    </div>
    <div>
        <div class="watchinfo-bottom center-block text-center">
            <p>{$infor}</p>
        </div>
    </div>
    <div style="width: 100%;height: 80px;"></div>
    <script type="text/javascript">
        var t = 60;
        var eEmpty = 1,
                eDiferent = 1,
                mEmpty = 1,
                mDiferent = 1,
                eError = 1;
        function btnOpacity(obj, k) {
            if (k == 1) {
                obj.css({
                    backgroundColor: "rgba(49,176,213,1)",
                    color: "white"
                });
            }
            if (k == -1) {
                obj.css({
                    color: "#333333",
                    backgroundColor: "rgba(49,176,213,0)"
                });
            }
        }
        function closeWindow(obj) {
            obj.css("display", "none");
        }
        function showForm(k, formId) {
            if (k == 0) {
                $(".fixed-div,.form").css("display", "none");
            }
            if (k == 1) {
                $(".fixed-div,.form,#userRegister,#userLogin").css("display", "block");
                $(formId).css("display", "none");
            }
        }

        //倒计时
        function countTime(obj) {
            obj.attr("disabled", "disabled");
            var count = setInterval(function () {
                obj.attr("value", t + "秒");
                t--;
                if (t < 0) {
                    t = 60;
                    clearInterval(count);
                    obj.removeAttr("disabled");
                    obj.attr("value", "获取验证码");
                }
            }, 1000);
        }
        function checkBtnStatus() {
            if (eEmpty == 0 || eDiferent == 0 || eError == 0) {
                $("#eRegisterButton").attr("disabled", "disabled");
            }
            if (mEmpty == 0 || mDiferent == 0) {
                $("#mRegisterButton").attr("disabled", "disabled");
            }
            if (eEmpty && eDiferent && eError) {
                $("#eRegisterButton").removeAttr("disabled");
            }
            if (mEmpty && mDiferent) {
                $("#mRegisterButton").removeAttr("disabled");
            }
        }
        function emailCompare() {
            var pwd1 = document.getElementById("password1").value;
            var pwd2 = document.getElementById("password2").value;
            if (pwd1.length == 0) {
                $("#pwd-empty").css("display", "block");
                eEmpty = 0;
                checkBtnStatus();
            } else {
                $("#pwd-empty").css("display", "none");
                eEmpty = 1;
                checkBtnStatus();
            }
            if (pwd1 != pwd2) {
                $("#pwd-diferent").css("display", "block");
                eDiferent = 0;
                checkBtnStatus();

            } else {
                $("#pwd-diferent").css("display", "none");
                eDiferent = 1;
                checkBtnStatus();
            }
        }
        function messegeCompare() {
            var pwd1 = document.getElementById("messege-password1").value;
            var pwd2 = document.getElementById("messege-password2").value;
            if (pwd1.length == 0) {
                $("#msg-pwd-empty").css("display", "block");
                mEmpty = 0;
                checkBtnStatus();
            } else {
                $("#msg-pwd-empty").css("display", "none");
                mEmpty = 1;
                checkBtnStatus();
            }
            if (pwd1 != pwd2) {
                $("#msg-pwd-diferent").css("display", "block");
                mDiferent = 0;
                checkBtnStatus();

            } else {
                $("#msg-pwd-diferent").css("display", "none");
                mDiferent = 1;
                checkBtnStatus();
            }
        }
        function checkEmail() {
            var eml = document.getElementById("Email").value;
            var i = /@([a-z0-9]){2,}./
            if (i.test(eml)) {
                $("#Email-error").css("display", "none");
                eError = 1;
                checkBtnStatus();

            } else {
                $("#Email-error").css("display", "block");
                eError = 0;
                checkBtnStatus();
            }
        }
        function changeTab(obj, _id) {
            obj.css({
                borderBottom: "1px solid white",
                backgroundColor: "white"
            }).siblings().css({borderBottom: "1px solid #c7c7c7", backgroundColor: "#c7c7c7"});
            $("#emailRegister,#messegeRegister").css("display", "none");
            $(_id).css("display", "block");
        }


        $(function () {

            //点击
            $("#reg-for-phone").click();

            //短信发送绑定事件
            $(".btn-get-phone").bind('click', function (e) {
                var str = document.getElementById("phone").value;
                var _self = this;
                $.post("{:U('Public/getPhoneCode')}", {phone: str}, function (ret) {
                    layer.msg(ret.info);
                    if (ret.status == 1) {
                        //倒计时
                        countTime($(_self));
                    }
                }, 'json');
            });

            $('#reg-phone-form').bind('submit', function (e) {
                e.preventDefault();
                if (!window.confirm('您确认注册么,注册资料将不可以修改')) {
                    return;
                }
                $.ajax({
                    type: "POST",
                    url: "{:U('public/register_phone')}",
                    data: $(this).serialize(),
                    dataType: "json",
                    success: function (data) {
                        if (data.status == 1) {
                            alert(data.info);
                            location.href = data.url;
                        } else {
                            layer.msg(data.info);
                        }
                    }
                });
                return false;
            });

            //登陆
            $("form[name=main_login]").submit(function () {
                $.ajax({
                    type: "POST",
                    url: "{:U('Public/login')}",
                    data: $(this).serialize(),
                    dataType: "json",
                    success: function (data) {
                        if (data.status == 1) {
                            alert(data.info);
                            window.location.href = data.url;
                        } else {
                            alert(data.info + '，请重新点击图片验证码');
                        }
                    }
                });
                return false;
            });

        });
    </script>
</block>